/** Part of Zombie Navigator
	Copyright © 2016  Zombie Navigator Developers
	
	@file
	@license AGPL-3.0+
	
*/ 'use strict';

// Content script for addon UIs
((w, p, o) => {
	const handlers = [];
	p.on('uiMsg', m => {
		handlers.forEach(f => f(m));
	});
	Object.defineProperty(w, 'zombieUI', {__proto__: null
		,value: Object.freeze({__proto__: null
			,activeUI: !!o.activeUI
			,receive (f) {
				handlers.push(f);
			}
			,sendCommand (id, d) {
				p.emit('uiComm', {id: id, data: d});
			}
		})
	});
})(this, self.port, self.options); // The only legit use of 'this'

// vim: ts=4 noet ai

